var MongoClient = require('mongodb').MongoClient;
const assert = require('assert');
function mongo() {
    return new Promise((resolve, reject)=> {
        const url = 'mongodb://localhost:27017';
        const dbName = 'smile-db';
        MongoClient.connect(url, {
            useNewUrlParser: true
        }, function (err, client) {
            assert.equal(null, err);
            var movies = client.db(dbName).collection('movies');
            resolve(movies.find({}).toArray())
            client.close()

        });
    })

}
module.exports ={
    mongo
}